import asyncio
from lib.net.index import wlan
from lib.websocket import action
from lib.config.index import websocket_config


def init():
    # 检查当前网络状态和网络模式
    wlan.connect()


async def run():
    await action.connect()
    while True:
        try:
            print(1)
            await action.heart_beat()
            data = await action.read()
            # print("ws recv:", data)
            await asyncio.sleep(websocket_config.get_interval())
        except Exception as e:
            print(e)


init()
asyncio.run(run())
